<!--菜谱的一个展示  -->
					<%@page import="com.wanmait.cookbook.vo.Cookbook"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.wanmait.cookbook.vo.Pager"%>
<ul class="cook-list" id="count">

	<!-- 进入页面默认加载 -->


	<%
	String name=(String)request.getAttribute("name");
							List<Cookbook> picToCookbooks = (List<Cookbook>) request.getAttribute("picToCookbooks");
							if (picToCookbooks.size() == 0) {
						%>
	<span>没有相关菜谱</span>
	<%
							} else {
								List<Integer> foodToCookCounts = (List<Integer>) request.getAttribute("foodToCookCounts");
								for (int i = 0; i < picToCookbooks.size(); i++) {
						%>

	<li class="clearfix"><a class="cook-img"
		href="<%=request.getContextPath() %>/CookbookServlet?action=cookbookShow&id=<%=picToCookbooks.get(i).getId() %>"
		style="background-size: cover; position: relative;"
		title="<%=picToCookbooks.get(i).getInfo()%>" target="_blank"
		one-link-mark="yes"> <img
			src="<%=request.getContextPath()%>/static/image/<%=picToCookbooks.get(i).getPic()%>"
			width="180" height="125" title="<%=picToCookbooks.get(i).getInfo()%>">
	</a>
		<div class="cook-info">
			<a class="cookname text-lips "
				href="<%=request.getContextPath() %>/CookbookServlet?action=cookbookShow&id=<%=picToCookbooks.get(i).getId() %>"
				target="_blank" one-link-mark="yes"><%=picToCookbooks.get(i).getTitle()%></a>
			<!-- <p class="major">嫩豆腐,里脊肉,蒜,葱,油,老抽,盐,水,水淀粉 </p> -->
			<span><%=picToCookbooks.get(i).getInfo()%></span>
			<div class="score">
				<!-- 收藏开始 -->
				<span class="shoucangzi">收藏</span> <img width="20" class="shoucang"
					src="<%=request.getContextPath()%>/img/shoucangkongxin.jpg">
				<!-- 收藏结束 -->
			</div>


			<div class="aut-num clearfix text-lips ">
				<a class="headicon"
					href="<%=request.getContextPath()%>/PersonalServlet?action=init&id=<%=picToCookbooks.get(i).getUserinfo().getId()%>"
					target="_blank" one-link-mark="yes"> <img
					src="<%=request.getContextPath()%>/static/image/<%=picToCookbooks.get(i).getUserinfo().getAvatar()%>"><%=picToCookbooks.get(i).getUserinfo().getName()%>
				</a> <a class="proicon" href="https:#" target="_blank"
					one-link-mark="yes"> </a>
			</div>
		</div></li>
	<%
		}
	%>
	<!-- 显示数字 -->
	<div class="mt20">
		<div class="pages">

			<%
				Pager pager = (Pager) request.getAttribute("pager");
			
					int start = 1;
					int end = pager.getPageCount();
					if (pager.getPageCount() > 5) {
						start = pager.getPageNo() - 2 < 1 ? 1 : pager.getPageNo() - 2;
						end = start + 4;
						if (end > pager.getPageCount()) {
							end = pager.getPageCount();
							start = end - 4;
						}
					}
					%>
				<a href="javascript:void(0)" class="prevPager" one-link-mark="yes">上一页</a>
					<%
					for (int i = start; i <= end; i++) {
						if(i==pager.getPageNo()){
							%><a href="javascript:void(0)" style="color:red"  class="aliaon" one-link-mark="yes"><%=i %></a>
						<% }else{
							%>
							<a href="javascript:void(0)" class="aliaon" one-link-mark="yes"><%=i %></a>
							<%
						}
			%>
			<%} %>
			<a href="javascript:void(0)" class="nextPager" one-link-mark="yes">下一页</a>
			<a href="javascript:void(0)" class="aliaon" one-link-mark="yes"><%=pager.getPageNo()%>/<%=pager.getPageCount() %></a>
		<!-- 上下页事件开始 -->
<script type="text/javascript">
$(function(){
	//上一页点击事件
	$(".prevPager").click(function(){
		var n=<%=pager.getPageNo()%>;
		$.ajax({
			url:"<%=request.getContextPath()%>/indexServlet",
			data:{action:"recipetypeSecondCookbookElse",pageNo:n-1,name:"<%=name%>"},
			success:function(mes){
				$("#showList").html(mes);
			}
			
		});
	});
	//下一页点击事件
	$(".nextPager").click(function(){
		var n=<%=pager.getPageNo()%>;
		$.ajax({
			url:"<%=request.getContextPath()%>/indexServlet",
			data:{action:"recipetypeSecondCookbookElse",pageNo:n+1,name:"<%=name%>"},
			success:function(mes){
				$("#showList").html(mes);
			}
			
		});
	});

})
</script>	
<!--上下页事件结束  -->			
			
			
		</div>
	</div>
	<!-- 显示数字的结束 -->
	<%
		}
	%>
</ul>
<!--一个菜谱展示结束  -->
<!-- 收藏事件开始 -->
<script type="text/javascript">
	$(function(){
		$(".shoucang").click(function(){
			var shoucangsrc=$(this).attr("src");
			if(shoucangsrc=="<%=request.getContextPath()%>/img/shoucangkongxin.jpg"){
				$(this).attr("src","<%=request.getContextPath()%>/img/shoucangshixin.jpg");
				$(this).prev().html("已收藏")
			}
			else{
				$(this).attr("src","<%=request.getContextPath()%>/img/shoucangkongxin.jpg");
				$(this).prev().html("收藏")
				}
			});
	});
</script>
<!-- 收藏事件结束 -->
